﻿using System;
using System.Collections.Generic;

namespace ShortcutToolbox.Core
{
    public class PluginMenu : IPluginMenu
    {
        public virtual string TextKey { get; set; }
        public virtual bool Enabled { get; set; } = true;
        public virtual string Text
        {
            get
            {
                if (TextKey == "-")
                    return TextKey;
                dynamic dylang = I18N.Current;
                string text = string.Empty;
                if (!string.IsNullOrEmpty(TextKey))
                    text = Convert.ToString(dylang[TextKey]);
                if (string.IsNullOrEmpty(text))
                    text = TextKey;
                return text;
            }
            set { TextKey = value; }
        }
        public virtual bool Visible { get; set; } = true;
        public virtual bool Checked { get; set; } = false;

        public virtual IList<IPluginMenu> SubItems { get; set; } = new List<IPluginMenu>();

        public event EventHandler StatusChanged;
        public event EventHandler Click;
        public event EventHandler Popup;
        public event EventHandler Select;

        public virtual void OnClick(EventArgs e)
        {
            Click?.Invoke(this, e);
        }

        public virtual void OnPopup(EventArgs e)
        {
            Popup?.Invoke(this, e);
        }

        public virtual void OnSelect(EventArgs e)
        {
            Select?.Invoke(this, e);
        }

        public virtual void RaiseStatusChange(EventArgs e)
        {
            StatusChanged?.Invoke(this, e);
        }
    }
}
